#1
#function Get-SomthingBasic
#{
#	Write-Host "this is"
#}

#function Get-SomethingAdvanced
#{
#	[CmdletBinding()]
#	param(
#		[Parameter(Mandatory,ValueFromPipeline)]
#		[ValidateSet("this,that")]
#		[string]$Param
#	)

#	Write-Host $Param
#}

#Get-SomthingBasic | Get-SomethingAdvanced


#2
function New-VirtualMachine
{
	[CmdletBinding()]
	param(
		[string]$VMName
	)
	switch($VMName){
		"SQLInjectAttackName"{
			Write-Error -Message "OMG! Someone's trying to hack our base!"
		}
		"AlreadyExists"{
			Write-Warning -Message "You got a problem. This VM already exists so you can't add it, dummy"
		}
		"DoesNotExistAlready"{
			Write-Verbose -Message "The VM does not already exist. You may proceed to add a new one with that name."
		}
		"FlakyIssue"{
			$ThatVariable ="notright"
			Write-Debug -Message "I will add this VM on host 123, blade 4564 on the molecule h2s squared"
		}
	}
}

#$ErrorActionPreference
#$WarningPreference
#$VerbosePreference
#$DebugPreference
#New-VirtualMachine -VMName "SQLInjectAttackName"
#New-VirtualMachine -VMName "SQLInjectAttackName" -ErrorAction Ignore
#New-VirtualMachine -VMName "AlreadyExists" -WarningAction Continue
#New-VirtualMachine -VMName "DoesNotExistAlready"
#New-VirtualMachine -VMName "DoesNotExistAlready" -Verbose 
#New-VirtualMachine -VMName "FlakyIssue" -Debug

New-VirtualMachine -VMName "AlreadyExists" -WarningVariable VMAlreadyExists
if($VMAlreadyExists){
	Add-Content -Path "c:\somelogfile.log" -Value $VMAlreadyExists
}
#New-VirtualMachine -VMName "SQLInjectAttackName" -ErrorVariable error
#if($error){
#	Add-Content -Path "c:\somelogfile.log" -Value $error
#}

Get-Content -Path "c:\somelogfile.log"
